package com.example.controller;

import com.example.model.dto.OrderDTO;
import com.example.model.dto.Result;
import com.example.service.IOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @program: backend
 * @author: zk
 * @create: 2023-04-23 19:15
 **/
@Slf4j
@RestController
@RequestMapping("/orders")
@Api(tags = "订单管理")
public class OrderController {

    @Resource
    private IOrderService orderService;

    @ApiOperation("创建订单信息")
    @PostMapping
    public Result createOrder(@RequestBody OrderDTO orderDTO, HttpServletRequest request) {
        return orderService.createOrder(orderDTO,request);
    }
    @GetMapping
    @ApiOperation("获取用户已支付订单的信息")
    public Result getOrder() {
        return orderService.getOrder();
    }

}
